<!doctype html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title></title> 
</head>
<style type="text/css">
	
div{width: 100px;height: 100px;background:red;line-height: 100px;text-align: center;color: white;position: absolute;}
</style>
<body>
<input type='button' value='生成div' id='ipt'>

<script type="text/javascript">
	ipt.onclick = function(){
		//1 3 5 7 9 top 100
		//0 4 8 12 top 0
		//2 6 10 top 200
		for(var i = 0;i < 100;i++){
			var oDiv = document.createElement('div');
			oDiv.innerHTML = i;
			if(i%2 == 1){
				oDiv.style.top = 100 + 'px';
			}
			if(i%4 == 0){
				oDiv.style.top = 0 + 'px';
			}
			if(i%4 == 2){
				oDiv.style.top = 200 + 'px';
			}
			oDiv.style.left = i * 100+'px';
			
			document.body.appendChild(oDiv);
		}
	}

</script>
</body>
</html>